<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>系统后台 - {$Think.config.INTENDANT_NAME} - by HemaCMS</title>
    <link href="__INTENDANT__/css/admin_style.css" rel="stylesheet" />
    <script src="__COMMON__/jquery.js"></script>
    <script src="__COMMON__/jquery.cookie.js"></script>

    <link href="__COMMON__/zTree/css/zTreeStyle/zTreeStyle.css"  rel="stylesheet" />
    <script src="__COMMON__/zTree/js/jquery.ztree.core-3.5.min.js"></script>
    <script src="__COMMON__/zTree/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script src="__COMMON__/layer/layer.js"></script>
    <script src="__INTENDANT__/js/iteny.intendant.js"></script> <!-- 公共easyui JS -->
	<link href="__INTENDANT__/css/icons.css" rel="stylesheet" />
    <link href="__INTENDANT__/css/iteny.css" rel="stylesheet" />

	<style type="text/css">
	.table_full{background: #fafafa url(__INTENDANT__/images/hr.png) 0 bottom repeat-x;margin-bottom: 0;padding: 10px;}
	.tree-icon{
		display: inline-block;
		width: 16px;
		height: 16px;
		vertical-align: top;
		overflow: hidden;
	}
	.ztree li span.button{margin: 3px;}
	.ztree{padding: 5px;}
	</style>

</head>
<body>
<div>
  <ul class="ztree" style="padding-top: 10px;">
    <li style="position:relative;"> <a title="全部展开、折叠 "><span style="position:relative;top:-3px;" class="button ico_open icons-arrow-arrow_refresh"></span><span id="ztree_expandAll" data="true">全部展开、折叠 </span></a> </li>
  </ul>
  <ul id="treeDemo" class="ztree">
  </ul>
</div>
<script type="text/javascript">

//配置
var setting = {
	// check: {
	// 	enable: true,
	// 	chkboxType:{ "Y" : "ps", "N" : "ps" }
	// },
    data: {
        simpleData: {
            enable: true,
            idKey: "id",
            pIdKey: "pid",
        }
    },
    callback: {
        beforeClick: function (treeId, treeNode) {
            if (treeNode.isParent) {
                zTree.expandNode(treeNode);
                return false;
            } else {
                return true;
            }
        },
		onClick:function(event, treeId, treeNode){
			//栏目ID
			var catid = treeNode.catid;
			//保存当前点击的栏目ID
			setCookie('tree_catid',catid,1);
		}
    }
};
//节点数据
var zNodes ={$json};
//zTree对象
var zTree = null;
$(function(){
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			// setCheck();
		// 	$("#py").bind("change", setCheck);
		// 	$("#sy").bind("change", setCheck);
		// 	$("#pn").bind("change", setCheck);
		// 	$("#sn").bind("change", setCheck);
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.expandAll(true);
		$("#ztree_expandAll").toggle(
			  function(){
			  zTree.expandAll(false);},
			  function(){
			  zTree.expandAll(true);});
		//定位到上次打开的栏目，进行展开tree_catid
		var tree_catid = getCookie('tree_catid');
		if(tree_catid){
			var nodes = zTree.getNodesByParam("catid", tree_catid, null);
			zTree.selectNode(nodes[0]);
		}

});
function setCookie(name, value, days) {
    var argc = setCookie.arguments.length;
    var argv = setCookie.arguments;
    var secure = (argc > 5) ? argv[5] : false;
    var expire = new Date();
    if(days==null || days==0) days=1;
    expire.setTime(expire.getTime() + 3600000*24*days);
    document.cookie = name + "=" + escape(value) + ("; path=/") + ((secure == true) ? "; secure" : "") + ";expires="+expire.toGMTString();
}
//读取cookie
function getCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1, c.length);
        }
        if (c.indexOf(nameEQ) == 0) {
            return c.substring(nameEQ.length, c.length);
        }
    };

    return null;
}
function openwinx(url,name,w,h) {
    if(!w) w=screen.width;
    if(!h) h=screen.height;
    //window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
    window.open(url,name);
}
</script>
</body>
</html>